package com.atguigu.gulimall.search.controller;

import com.atguigu.common.to.es.SkuEsModel;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.search.service.ProductSaveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/search/save")
public class ElasticSaveController {

    @Autowired
    ProductSaveService productSaveService;

    /**
     * es中保存上架的商品
     * @return
     */
    @RequestMapping("/product")
    public boolean productStatusUp(@RequestBody List<SkuEsModel> skuEsModelList) {

          boolean flag=false;
        try {
            flag=productSaveService.saveProductUp(skuEsModelList);
        } catch (Exception e) {
            log.info("商品上传es失败");
        }
        return flag;
    }







}
